﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Mvc;

namespace MvcSupplantCaching.Demo.Controllers
{
    public class TestController : Controller
    {
        private OutputCacheManager _manager;

        public TestController()
        {
            _manager = OutputCacheManager.Instance;
        }

        [SupplantOutputCache(CacheProfile = "HomeIndex")]
        public ActionResult Index()
        {
            _manager.AddOutputCacheDependency("myKey");
            return View();
        }

        public ActionResult Bust()
        {
            OutputCache.Instance.Remove("myKey");
            return RedirectToAction("Index", "Test");
        }
    }
}